//
//  EmotIconGroupManager.swift
//  emotIcon
//
//  Created by 半缘君 on 15/12/15.
//  Copyright © 2015年 banyuanjun.cn. All rights reserved.
//

import UIKit

class EmotIconGroupManager {
    static let shareEmotManager = EmotIconGroupManager()
    var packages:[EmotIconGroup] = [EmotIconGroup]()
    
   private init() {
        //拼接路径
    packages.append(EmotIconGroup(dict: ["group_name_cn":"最近"]))
    
    let path = NSBundle.mainBundle().pathForResource("emoticons.plist", ofType: nil, inDirectory: "Emoticons.bundle")!
    let dic = NSDictionary(contentsOfFile: path) as! [String:AnyObject]
    
    let arr = dic["packages"] as! [[String:AnyObject]]
    
    for d in arr {

 /// 加载表情包plist文件
        let dic = loadEmotIconPlist(d["id"]! as! String)
        let emotIconGroup = EmotIconGroup(dict: dic)
        packages.append(emotIconGroup)
    }
//    print(packages)

    
    }
}
// MARK: - 加载表情组plist
extension EmotIconGroupManager {
    private func loadEmotIconPlist(name:String) -> [String:AnyObject]{
        let path = NSBundle.mainBundle().pathForResource("info.plist", ofType: nil, inDirectory: "Emoticons.bundle/\(name)")!
        return NSDictionary(contentsOfFile: path) as! [String:AnyObject]
    }

}
